<template>
  <div id="centerRight1">
    <div class="bg-color-black">
      <div class="d-flex pt-2 pl-2">
        <span>
          <icon name="chart-line" class="text-icon"></icon>
        </span>
        <div class="d-flex">
          <span class="fs-xl text mx-2">工序碳排放占比榜单</span>
        </div>
      </div>
      <div class="d-flex jc-center body-box">
        <dv-scroll-board class="dv-scr-board" :config="config"/>
      </div>
    </div>
  </div>
</template>

<script>
import {queryAllProcessEmissionOrigin} from "@/api/carbon-manage/data";

export default {
  data() {
    return {
      config: {
        header: ['工序', '占比'],
        data: [
          ['<span style="text-overflow: ellipsis" title="组件1">组件1</span>', "<span  class='colorGrass'>↑75%</span>"],
          ['组件2', "<span  class='colorRed'>↓33%</span>"],
          ['组件3', "<span  class='colorGrass'>↑100%</span>"],
          ['组件4', "<span  class='colorGrass'>↑94%</span>"],
          ['组件5', "<span  class='colorGrass'>↑95%</span>"],
          ['石灰石/白云石焙烧工序', "<span  class='colorGrass'>↑63%</span>"],
          ['组件7', "<span  class='colorGrass'>↑84%</span>"],
          ['组件8', "<span  class='colorRed'>↓46%</span>"],
          ['组件9', "<span  class='colorRed'>↓13%</span>"],
          ['组件10', "<span  class='colorGrass'>↑76%</span>"]
        ],
        rowNum: 7, //表格行数
        headerHeight: 35,
        headerBGC: '#0f1325', //表头
        oddRowBGC: '#0f1325', //奇数行
        evenRowBGC: '#171c33', //偶数行
        index: true,
        columnWidth: [50],
        align: ['center']
      }
    }
  },
  mounted() {
    this.loadData();
  },
  methods: {
    loadData() {
      queryAllProcessEmissionOrigin(new Date().getFullYear()).then(res => {
        console.log(res.data);
        let data = res.data.map(item => {
          return [
            `<span style="text-overflow: ellipsis" title="${item.processName}">${item.processName}</span>`,
            `<span class='colorGrass'>${item.percent}</span>`
          ];
        });
        this.config = {
          header: ['工序', '占比'],
          data: data,
          rowNum: 7, //表格行数
          headerHeight: 35,
          headerBGC: '#0f1325', //表头
          oddRowBGC: '#0f1325', //奇数行
          evenRowBGC: '#171c33', //偶数行
          index: true,
          columnWidth: [50],
          align: ['center']
        }
      })
    },
  }
}
</script>

<style lang="scss" scoped>
$box-height: 410px;
$box-width: 300px;
#centerRight1 {
  padding: 20px 16px 16px;
  height: $box-height;
  width: $box-width;
  border-radius: 5px;

  .bg-color-black {
    height: $box-height - 30px;
    border-radius: 10px;
  }

  .text {
    color: #c3cbde;
  }

  .body-box {
    border-radius: 10px;
    overflow: hidden;

    .dv-scr-board {
      width: 270px;
      height: 420px;
    }
  }
}
</style>
